package com.fy56.platform.logistics.restful.api.swagger;

import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@EnableWebMvc
@EnableSwagger
@ComponentScan(basePackages = {"com.fy56.platform.logistics.restful.api.controller"})
public class SwaggerConfig {

	private SpringSwaggerConfig springSwaggerConfig;

	@Autowired
	public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
		this.springSwaggerConfig = springSwaggerConfig;
	}

	/**
	 * 链式编程 来定制API样式 后续会加上分组信息
	 * 
	 * @return
	 */
	@Bean
	public SwaggerSpringMvcPlugin customImplementation() {
		return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
				.apiInfo(apiInfo())
				//.includePatterns(".*")
				//.useDefaultResponseMessages(false)
				//.pathProvider(new GtPaths())
				.apiVersion("1.0").build();

	}

	private ApiInfo apiInfo() {
		ApiInfo apiInfo = new ApiInfo("BS-TMS系统API接口平台",
				"提供所有Restful接口", "",
				"", "飞扬软件", "");
		/*
		ApiInfo apiInfo = new ApiInfo(
				"My Apps API Title",
				"My Apps API Description",
				"My Apps API terms of service",
				"My Apps API Contact Email",
				"My Apps API Licence Type",
				"My Apps API License URL")
		*/
		return apiInfo;
	}
}